/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package ru.jSkyRoom.bridge.major;

import java.util.Collection;
import java.util.Collections;
import ru.jSkyRoom.interfaces.major.Light;
import ru.jSkyRoom.interfaces.major.Projectile;
import ru.jSkyRoom.interfaces.major.Texture;
import ru.jSkyRoom.interfaces.major.Weapon;
import ru.jSkyRoom.interfaces.stub.Explosion;
import ru.jSkyRoom.interfaces.stub.JSkySound;
import ru.jSkyRoom.interfaces.sub.AltTexture;
import ru.jSkyRoom.interfaces.sub.JSkyModel;
import skyproc.FormID;
import skyproc.Model;
import skyproc.PROJ;
import skyproc.PROJ.ProjectileFlag;

/**
 *
 * @author Rakev
 */
public class ProjectileBridge extends NamedMajorBridge<PROJ> implements Projectile {

    public ProjectileBridge(PROJ adapting) {
        super(adapting);
    }

    @Override
    public JSkyModel getModel() {
        Model model = getRawObject().getModelData();
        return getBridgeFactory().createBridge(model);
    }

    @Override
    public JSkyModel getEffectModel() {
        return new JSkyModel() {

            @Override
            public Collection<AltTexture> getAltTextures() {
                return Collections.EMPTY_LIST;
            }

            @Override
            public String getPath() {
                return getRawObject().getEffectModel();
            }

            @Override
            public void setPath(String path) {
                getRawObject().setEffectModel(path);
            }
        };
    }

    @Override
    public boolean getFlag(ProjectileFlag flag) {
        return getRawObject().get(flag);
    }

    @Override
    public void setFlag(ProjectileFlag flag) {
        getRawObject().set(flag, true);
    }

    @Override
    public void unsetFlag(ProjectileFlag flag) {
        getRawObject().set(flag, false);
    }

    @Override
    public PROJ.ProjectileType getProjectileType() {
        return getRawObject().getProjType();
    }

    @Override
    public void setProjectileType(PROJ.ProjectileType type) {
        getRawObject().setProjType(type);
    }

    @Override
    public float getGravity() {
        return getRawObject().getGravity();
    }

    @Override
    public void setGravity(float gravity) {
        getRawObject().setGravity(gravity);
    }

    @Override
    public float getSpeed() {
        return getRawObject().getSpeed();
    }

    @Override
    public void setSpeed(float speed) {
        getRawObject().setSpeed(speed);
    }

    @Override
    public float getRange() {
        return getRawObject().getRange();
    }

    @Override
    public void setRange(float range) {
        getRawObject().setRange(range);
    }

    @Override
    public Light getLight() {
        FormID id = getRawObject().getLight();
        return getFinderFactory().createLightFinder().find(id);
    }

    @Override
    public void setLight(Light light) {
        FormID id = getIdProducer().produce(light);
        getRawObject().setLight(id);
    }

    @Override
    public Light getMuzzleLight() {
        FormID id = getRawObject().getMuzzleLight();
        return getFinderFactory().createLightFinder().find(id);
    }

    @Override
    public void setMuzzleLight(Light light) {
        FormID id = getIdProducer().produce(light);
        getRawObject().setMuzzleLight(id);
    }

    @Override
    public float getTracerChance() {
        return getRawObject().getTracerChance();
    }

    @Override
    public void setTracerChance(float chance) {
        getRawObject().setTracerChance(chance);
    }

    @Override
    public float getProximity() {
        return getRawObject().getProximity();
    }

    @Override
    public void setProximity(float proximity) {
        getRawObject().setProximity(proximity);
    }

    @Override
    public float getTimer() {
        return getRawObject().getTimer();
    }

    @Override
    public void setTimer(float timer) {
        getRawObject().setTimer(timer);
    }

    @Override
    public Explosion getExplosionType() {
        FormID id = getRawObject().getExplosionType();
        return getFinderFactory().createExplosionFinder().find(id);
    }

    @Override
    public void setExplosionType(Explosion type) {
        FormID id = getIdProducer().produce(type);
        getRawObject().setExplosionType(id);
    }

    @Override
    public JSkySound getSound() {
        FormID soundId = getRawObject().getSound();
        return getFinderFactory().createJSkySoundFinder().find(soundId);
    }

    @Override
    public void setSound(JSkySound sound) {
        FormID id = getIdProducer().produce(sound);
        getRawObject().setSound(id);
    }

    @Override
    public float getMuzzleFlashDuration() {
        return getRawObject().getMuzzleFlashDuration();
    }

    @Override
    public void setMuzzleFlashDuration(float duration) {
        getRawObject().setMuzzleFlashDuration(duration);
    }

    @Override
    public float getFadeDuration() {
        return getRawObject().getFadeDuration();
    }

    @Override
    public void setFadeDuration(float duration) {
        getRawObject().setFadeDuration(duration);
    }

    @Override
    public float getImpactForce() {
        return getRawObject().getImpactForce();
    }

    @Override
    public void setImpactForce(float force) {
        getRawObject().setImpactForce(force);
    }

    @Override
    public JSkySound getExplosionSound() {
        FormID id = getRawObject().getExplosionSound();
        return getFinderFactory().createJSkySoundFinder().find(id);
    }

    @Override
    public void setExplosionSound(JSkySound sound) {
        FormID id = getIdProducer().produce(sound);
        getRawObject().setExplosionSound(id);
    }

    @Override
    public JSkySound getDisableSound() {
        FormID id = getRawObject().getDisableSound();
        return getFinderFactory().createJSkySoundFinder().find(id);
    }

    @Override
    public void setDisableSound(JSkySound sound) {
        FormID id = getIdProducer().produce(sound);
        getRawObject().setDisableSound(id);
    }

    @Override
    public Weapon getDefaultWeaponSource() {
        FormID id = getRawObject().getDefaultWeaponSource();
        return getFinderFactory().createWeaponFinder().find(id);
    }

    @Override
    public void setDefaultWeaponSource(Weapon weaponSource) {
        FormID id = getIdProducer().produce(weaponSource);
        getRawObject().setDefaultWeaponSource(id);
    }

    @Override
    public float getConeSpread() {
        return getRawObject().getConeSpread();
    }

    @Override
    public void setConeSpread(float spread) {
        getRawObject().setConeSpread(spread);
    }

    @Override
    public float getCollisionRadius() {
        return getRawObject().getCollisionRadius();
    }

    @Override
    public void setCollisionRadius(float radius) {
        getRawObject().setCollisionRadius(radius);
    }

    @Override
    public float getLifetime() {
        return getRawObject().getLifetime();
    }

    @Override
    public void setLifetime(float lifetime) {
        getRawObject().setLifetime(lifetime);
    }

    @Override
    public float getRelaunchInterval() {
        return getRawObject().getRelaunchInterval();
    }

    @Override
    public void setRelaunchInterval(float interval) {
        getRawObject().setRelaunchInterval(interval);
    }

    @Override
    public Texture getDecalData() {
        FormID id = getRawObject().getDecalData();
        return getFinderFactory().createTextureFinder().find(id);
    }

    @Override
    public void setDecalData(Texture decal) {
        FormID id = getIdProducer().produce(decal);
        getRawObject().setDecalData(id);
    }

}
